<!--
Description :開窗project code挑選
 -->
<%@page contentType="text/html; charset=UTF-8" language="java" import="java.util.*"%>
<%@page import="com.pub.database.*"%>
<%@page import="com.pub.tools.*"%>

<jsp:useBean id="webFunction" scope="request" class="com.pub.web.WebFunction"/>

<!-- 以下為DataView 共用設定 -->
<jsp:useBean id="DataViewForm" scope="request" class="com.pub.database.DataViewForm"/>
<jsp:setProperty name="DataViewForm" property="submitMethod" value="POST"/>
<jsp:setProperty name="DataViewForm" property="pageRowCount" value="10"/>
<jsp:setProperty name="DataViewForm" property="nowPageNum"/>
<jsp:setProperty name="DataViewForm" property="dataViewAction"/>
<jsp:setProperty name="DataViewForm" property="filterCol"/>
<jsp:setProperty name="DataViewForm" property="filterValue"/>
<jsp:setProperty name="DataViewForm" property="dvOrderByFields"/>
<jsp:setProperty name="DataViewForm" property="dvOrderBySeq"/>

<!-- DataView 設定結束 -->
<%

  webFunction.setPortal_to_session(request); //set session from portal
  if (session.getAttribute("u_id") == null) {
    session.setAttribute("path", String.valueOf(request.getRequestURI()));
    session.setAttribute("param", null);
    response.sendRedirect("login.jsp?prg_no=find_project_code.jsp");
    return;
  }

  String db_alias = request.getParameter("DB_ALIAS")!=null ? request.getParameter("DB_ALIAS"):"";
  if(db_alias.equals("")){return;}
  com.pub.database.DataView DataView=null;
  String strDataViewHtml = null;
  String find_project_name = null;
  String find_part_no = null;

  try{
      find_project_name = request.getParameter("find_project_name")!=null && !request.getParameter("find_project_name").equals("null") ? request.getParameter("find_project_name").toString() : "";
      find_part_no = request.getParameter("find_part_no")!=null && !request.getParameter("find_part_no").equals("null") ? request.getParameter("find_part_no").toString() : "";

      StringBuffer stbSQL = new   StringBuffer();
      StringBuffer stbCondition = new StringBuffer();
      StringBuffer stbPageActionURI = new StringBuffer("find_project_code.jsp");
                   stbPageActionURI.append("?DB_ALIAS=");
                   stbPageActionURI.append(request.getParameter("DB_ALIAS"));
                   stbPageActionURI.append("&find_project_name=");
                   stbPageActionURI.append(request.getParameter("find_project_name"));
                   stbPageActionURI.append("&find_part_no=");
                   stbPageActionURI.append(request.getParameter("find_part_no"));
      stbCondition.append("product_type is not null");

      if(find_project_name!=null && !find_project_name.equals("")){
        stbCondition.append(" and UPPER(project_name) like UPPER('%");
        stbCondition.append(find_project_name);
        stbCondition.append("%')");
      }

      if(find_part_no!=null && !find_part_no.equals("")){
        stbCondition.append(" and UPPER(part_no) like UPPER('%");
        stbCondition.append(find_part_no);
        stbCondition.append("%')");
      }

      DataViewForm.setFieldsList("rownum,project_code,project_name,part_no,ped_empno,dept_no,product_type,(select des1 from wkf_udc where flow_code='PRF' and udc='A' and code=product_type) as product_line_desc,(select userno from pps_bominqsec,pnl_employee where userno=employee_no and employee_st='A' and rollcode='G' and projectcode=prj.project_code and rownum=1) hw_leader");
      DataViewForm.setTablesList("wkf_project prj");
      DataViewForm.setSQLCondition(stbCondition.toString());
      DataViewForm.setOrderByFields("project_code");
      DataViewForm.setOrderBySeq("asc");
      DataViewForm.setGroupBy(null);
      DataViewForm.setHaving(null);

      boolean blnDebug = false;
      String strColRelation[][] = new String[9][];
      strColRelation[0] = new String[5];
      strColRelation[1] = new String[5];
      strColRelation[2] = new String[5];
      strColRelation[3] = new String[3];
      strColRelation[4] = new String[5];
      strColRelation[5] = new String[3];
      strColRelation[6] = new String[5];
      strColRelation[7] = new String[5];
      strColRelation[8] = new String[5];


      strColRelation[0][0] = "'SEL'";
      strColRelation[0][1] = "INPUT";
      strColRelation[0][2] = "WIDTH='10%' ALIGN=\"CENTER\"";
      strColRelation[0][3] = "<input type='radio' CLASS='button b_normal' name='sel'  onclick=\"javascript:retVal(%sn%);\" value=";
      strColRelation[0][4] = "1";

      strColRelation[1][0] = "'專案編號'";
      strColRelation[1][1] = "INPUT";
      strColRelation[1][2] = " nowrap WIDTH=\"10%\"";
      strColRelation[1][3] = "<input type=\"text\" name=\"project_code%sn%\" class=\"input_noborder\" value=";
      strColRelation[1][4] = "1";

      strColRelation[2][0] = "'專案名稱'";
      strColRelation[2][1] = "INPUT";
      strColRelation[2][2] = "nowrap width=\"30%\"";
      strColRelation[2][3] = "<input type=\"text\" name=\"project_name%sn%\" class=\"input_noborder\" value=";
      strColRelation[2][4] = "2";

      strColRelation[3][0]="'Model名稱'";
      strColRelation[3][1]="0";
      strColRelation[3][2]="NOWRAP WIDTH='10%' ALIGN=\"CENTER\"";

      strColRelation[4][0]="'PED工程師'";
      strColRelation[4][1]="INPUT";
      strColRelation[4][2] = "nowrap width=\"10%\"";
      strColRelation[4][3]="<input type=\"text\" name=\"ped_empno%sn%\" class=\"input_noborder\" value=";
      strColRelation[4][4] = "4";

      strColRelation[5][0]="'部門代號'";
      strColRelation[5][1]="0";
      strColRelation[5][2]="NOWRAP WIDTH='10%' ALIGN=\"CENTER\"";

      strColRelation[6][0] = "HIDDEN";
      strColRelation[6][1] = "INPUT";
      strColRelation[6][2] = "nowrap width=\"10%\"";
      strColRelation[6][3] = "<input type=\"hidden\" name=\"project_type%sn%\" class=\"input_noborder\" value=";
      strColRelation[6][4] = "6";

      strColRelation[7][0] = "HIDDEN";
      strColRelation[7][1] = "INPUT";
      strColRelation[7][2] = "nowrap width=\"10%\"";
      strColRelation[7][3] = "<input type=\"hidden\" name=\"product_line_desc%sn%\" class=\"input_noborder\" value=";
      strColRelation[7][4] = "7";

      strColRelation[8][0] = "HIDDEN";
      strColRelation[8][1] = "INPUT";
      strColRelation[8][2] = "nowrap width=\"10%\"";
      strColRelation[8][3] = "<input type=\"hidden\" name=\"hw_leader%sn%\" class=\"input_noborder\" value=";
      strColRelation[8][4] = "8";




/*
select project_code,project_name,product_type,(select des1 from wkf_udc where flow_code='PRF' and udc='A' and code=product_type) as product_line_desc,ped_empno,(select userno from pps_bominqsec where rollcode='G' and projectcode=prj.project_code and rownum=1) hw_leader
from wkf_project prj where product_type is not null and project_code='P0103124'
*/


      DataViewForm.setColRelation(strColRelation);//將欄位相關設定殖入ActionForm

      DataViewForm.setJumpPageButtonShow(false);   //是否要秀出上下頁按鈕
      DataViewForm.setPageBtnOnTop(false);         //將button and rows info 秀在頂端
      DataViewForm.setPageBtnOnButtom(true);      //將button and rows info 秀在底端
      DataViewForm.setFilterShow(false);           //是否要秀出過濾選擇欄位
      DataViewForm.setJumpPageShow(true);         //是否要秀出跳頁下拉式選單
      DataViewForm.setRowsInfoShow(true);         //是否要秀出筆數資訊
      DataViewForm.setRowPageShow(false);          //是否要秀出每頁筆數控制欄
      DataViewForm.setExcelShow(false);           //是否要秀出轉Excel button
      DataViewForm.setOrderEnable(false);          //是否要提供排序點選功能
      DataViewForm.setShowHeaderWhenNoData(true);//當DataView無資料時是否要秀Header

      DataViewForm.setTableDataTrHtml("id='tr%sn%' name='tr%sn%' onmouseover=\"this.className='td_content_over'\" onmouseout=\"this.className='td_content'\"");
      DataViewForm.setTableHeaderHtml("class='td_head_grid' align='center'");
      //設定上一頁與下一頁按鈕的form action(通常為母頁即本頁)
      DataViewForm.setPageActionURI(stbPageActionURI.toString());
      DataView=new com.pub.database.DataView(db_alias,false,"utf-8","utf-8");
      strDataViewHtml = DataView.getOutputDataView(DataViewForm);
    }//try
catch(Exception e){
  e.printStackTrace();
}finally{
  DataViewForm.setColRelation(null);
  DataViewForm=null;
  DataView=null;
}%>
<html>
<head>
<title>Project Code List</title>
<LINK HREF="/PUBPAGE/general/workflow.css" REL="STYLESHEET" TYPE="TEXT/CSS">
<script type="text/javascript" language="javascript1.2" src="/PUBPAGE/general/commscript.js" ></script>
<script type="text/javascript" language="javascript1.2" src="/TPS/general/check_project_code.js" ></script>
<script type="text/javascript" language="javascript1.2">
function retVal(varSN){

  window.returnValue = document.all.item('project_code'+varSN).value + "," +
                       document.all.item('project_name'+varSN).value + "," +
                       document.all.item('project_type'+varSN).value + "," +
                       document.all.item('product_line_desc'+varSN).value + "," +
                       document.all.item('ped_empno'+varSN).value + "," +
                       document.all.item('hw_leader'+varSN).value ;
  window.close();
}
</script>
<base target='_self'/>
</head>
<body>
<form method="POST" action="<%=request.getRequestURI()%>">
<input type="hidden" name="DB_ALIAS" value="<%=db_alias%>">
<table>
<tr>
  <th>專案名稱：</th>
  <td><input type="text" name="find_project_name" class="input" size="15" value="<%=find_project_name!=null && !find_project_name.equals("") ? find_project_name : ""%>"></td>
  <td rowspan="2"><input type="submit" value="尋找" class="button b_normal"></td>
</tr>
<tr>
<th>Model名稱：</th>
<td><input type="text" name="find_part_no" class="input" size="15" value="<%=find_part_no!=null && !find_part_no.equals("") ? find_part_no : "" %>"></td>
</tr>
</table>
</form>
<%=strDataViewHtml==null?"":strDataViewHtml %>
</body>
</html>

